<?php
/**
 * Created by PhpStorm.
 * User: HUNG NGUYEN
 * Date: 4/7/14
 * Time: 10:34 PM
 */

class InputHelper
{
    public static function getInput($input,$name,$default_value=null)
    {
       try
       {
            if(array_key_exists($name,$input))
            {
                return $input[$name];
            }
           else
           {
               if($default_value!=null)
               {
                    return $default_value;
               }
               else
               {
                   throw new Exception("$name invalid");
               }
           }
       }
       catch(Exception $e)
       {
           throw $e;
       }
    }
} 